cmake_minimum_required(VERSION 3.20)

project(CppDemo LANGUAGES C CXX)

if (CMAKE_SIZEOF_VOID_P EQUAL 4)
    set(COMPILEBIT "32")
else ()
    set(COMPILEBIT "64")
endif ()

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
    message("Setting build type to 'RelWithDebInfo' as none was specified.")
    set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
    # Set the possible values of build type for cmake-gui
    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
            "MinSizeRel" "RelWithDebInfo")
endif ()

set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

if (0)
    #设置可执行文件的输出目录
    SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/out/bin${COMPILEBIT})
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/out/bin${COMPILEBIT}/${CMAKE_BUILD_TYPE})
    #设置库文件的输出目录
    SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/out/lib${COMPILEBIT})
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/out/lib${COMPILEBIT}/${CMAKE_BUILD_TYPE})
else ()
    #设置可执行文件的输出目录
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/out/bin${COMPILEBIT}/Debug)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/out/bin${COMPILEBIT}/Release)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_SOURCE_DIR}/out/bin${COMPILEBIT}/MinSizeRel)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_SOURCE_DIR}/out/bin${COMPILEBIT}/RelWithDebInfo)
    #设置库文件的输出目录
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/out/lib${COMPILEBIT}/Debug)
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/out/lib${COMPILEBIT}/Release)
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_SOURCE_DIR}/out/lib${COMPILEBIT}/MinSizeRel)
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_SOURCE_DIR}/out/lib${COMPILEBIT}/RelWithDebInfo)
endif ()

add_subdirectory(Test)
add_subdirectory(AnyDemo)
add_subdirectory(EnumDemo)
add_subdirectory(RegexDemo)
add_subdirectory(AtomicDemo)
add_subdirectory(RangesDemo)
add_subdirectory(RandomDemo)
add_subdirectory(VariantDemo)
add_subdirectory(OptionalDemo)
add_subdirectory(ThreadPoolDemo)
add_subdirectory(SharedMemoryDemo)
add_subdirectory(PriorityQueueDemo)
add_subdirectory(SmartPointer)
add_subdirectory(AttributeDemo)
add_subdirectory(VariableParameter)
add_subdirectory(PoolDemo)
add_subdirectory(ProcessDemo)
add_subdirectory(shuffle)
add_subdirectory(piecewise_construct)
add_subdirectory(Timer)
add_subdirectory(Coroutine)
add_subdirectory(polymorphism)
add_subdirectory(Concepts)
add_subdirectory(MemFunction)
add_subdirectory(ToStr)
add_subdirectory(TokenManager) 
#add_subdirectory(BoostDemo)

if (WIN32)
    add_subdirectory(IOCP)
    add_subdirectory(ModuleDemo)
    add_subdirectory(WinRegDemo)
    add_subdirectory(Timer_win)
    add_subdirectory(CriticalSectionDemo) # 临界区是windows平台的API接口
    if (MSVC)
        if (${MSVC_TOOLSET_VERSION} EQUAL 143)
            # message(${MSVC_VERSION})
            # message(${MSVC_TOOLSET_VERSION})
            # message(${CMAKE_CXX_COMPILER_VERSION})
            add_subdirectory(FormatDemo) # format库目前只有最新的msvc支持ok
        endif ()
    endif (MSVC)
endif (WIN32)


